package com.ask.config;

import com.google.gson.Gson;
import spark.ModelAndView;
import spark.template.freemarker.FreeMarkerEngine;

import java.util.HashMap;
import java.util.Map;

import static spark.Spark.*;

/**
 * @author hzwangzhongkui on 15/10/29 .
 */

public class WebConfig {

    private Gson gson = new Gson();

    public WebConfig() {
        config();
        routes();
    }

    private void config() {
        staticFileLocation("/public");
        port(8080);
        threadPool(200, 2, 30000);

    }

    private void routes() {

        before("/", (req, res) -> {
            halt();
        });

        get("/", (req, res) -> {
            Map<String, Object> map = new HashMap<>();
            return new ModelAndView(map, "timeline.ftl");
        }, new FreeMarkerEngine());
    }
}
